package com.software.lease.web.admin.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.software.lease.model.entity.LabelInfo;
import com.software.lease.model.enums.ItemType;
import com.software.lease.web.admin.service.LabelInfoService;
import com.software.lease.web.admin.mapper.LabelInfoMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author liubo
* @description 针对表【label_info(标签信息表)】的数据库操作Service实现
* @createDate 2023-07-24 15:48:00
*/
@Service
public class LabelInfoServiceImpl extends ServiceImpl<LabelInfoMapper, LabelInfo>
    implements LabelInfoService{

    @Autowired
    private LabelInfoMapper labelInfoMapper;

    /**
     * 根据类型查询标签列表
     * @param type
     * @return
     */
    @Override
    public List<LabelInfo> listLabInfo(ItemType type) {
        if(type == null){
            List<LabelInfo> list = labelInfoMapper.selectAll();
            return list;
        }else {
            List<LabelInfo> list = labelInfoMapper.selectByType(type);
            return list;
        }
    }

    @Override
    public void deleteById(Long id) {
        labelInfoMapper.deleteByid(id);
    }

    /**
     * 通过公寓id删除标签
     * @param apartmentId
     */
    @Override
    public void removeByApartmentId(Long apartmentId) {
        labelInfoMapper.removeByApartmentId(apartmentId);
    }
}




